<%@ page import="employee.Employee" %><%--
  Created by IntelliJ IDEA.
  User: 王宇航
  Date: 2023/3/11
  Time: 17:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Editer</title>
</head>

<body style="text-align: center">
<h1 style="color: aqua">EditerPage</h1>
<form action="/employee" method="post">
    <%
        Employee employee = (Employee) session.getAttribute("employee");
        if (employee  == null){
            session.setAttribute("error","can't access editerPage !!");
            response.sendRedirect("index.jsp");
        }
    %>
    <%
        Object  o = session.getAttribute("role");
        int role = -1;
        if (o != null){
            role = (int) session.getAttribute("role");
        }
        if (role != 1){
            session.setAttribute("error","Your are not admin!");
            response.sendRedirect("index.jsp");
        }
    %>
    <input type="hidden" name="action" value="Update">
    <input type="hidden" name="id" placeholder="ID"  value="<%= employee.getId()%>"><br>
    <input type="text" name="name" placeholder="NAME" value="<%= employee.getName()%>" required><br>
    <input type="password" name="password" placeholder="PASSWORD"  value="<%= employee.getPassword()%>" required><br>
    <input type="number" name="age" placeholder="AGE"  value="<%= employee.getAge()%>" required><br>
    <input type="text" name="gender" placeholder="GENDER"  value="<%= employee.getGender()%>" required><br>
    <input type="submit" value="Update">
</form>
</body>
</html>
